昨天用好設定鈴聲的畫面,今天繼續來完成剩下兩個設定畫面。
這裡先將輸入附註用的Label設定好內容,包含初始內容,清除按鈕的樣式以及delegate。
        LabelPageLabel.placeholder = "附註:"
        LabelPageLabel.clearButtonMode = .whileEditing
        LabelPageLabel.returnKeyType = .done
        LabelPageLabel.delegate = self
最後在這個函式裡設定在輸入完成時pop回上一個畫面。
    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        self.view.endEditing(true)
        self.navigationController?.popViewController(animated: true)
        
        return true
    }
這裡用了兩個陣列,第一個單純只是存取日期,第二個陣列則是用來存取哪些日期是被選擇的,被選擇的日期會跟其他日期有不同的顯示。
    let weekDay = ["週日", "週一", "週二", "週三", "週四", "週五", "週六"]
    var repeatDayCheck = [false, false, false, false, false, false, false]
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return weekDay.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = RepeatPageTableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! RepeatPageTableViewCell
        cell.WeekLabel.text = "\(weekDay[indexPath.row])"
        
        if repeatDayCheck[indexPath.row] {
            cell.accessoryType = .checkmark
        } else {
            cell.accessoryType = .none
        }
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        repeatDayCheck[indexPath.row] = !repeatDayCheck[indexPath.row]
        RepeatPageTableView.reloadData()
    }
今天用完所有的設定畫面了,明天要來處理這些畫面間傳值的問題。